home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / tclX-6.4 / help / control / uplevel < prev    next >
Encoding:
Text File  |  1992-12-17  |  2.4 KB  |  41 lines

  1.           uplevel ?level? command ?command ...?
  2.                All of the command arguments  are  concatenated  as  if
  3.                they  had  been  passed  to  concat; the result is then
  4.                evaluated in the variable context indicated  by  level.
  5.                Uplevel  returns  the  result  of  that evaluation.  If
  6.                level is an integer, then it gives a distance  (up  the
  7.                procedure  calling  stack) to move before executing the
  8.                command.  If level consists of # followed by  a  number
  9.                then  the  number  gives  an absolute level number.  If
  10.                level is omitted then it defaults to 1.   Level  cannot
  11.                be  defaulted if the first command argument starts with
  12.                a digit or #.  For example, suppose  that  procedure  a
  13.                was  invoked  from top-level, and that it called b, and
  14.                that b called c.  Suppose that c  invokes  the  uplevel
  15.                command.   If  level  is  1 or #2  or omitted, then the
  16.                command will be executed in the variable context of  b.
  17.                If  level  is 2 or #1 then the command will be executed
  18.                in the variable context of a.  If level is 3 or #0 then
  19.                the  command will be executed at top-level (only global
  20.                variables will be visible).  The uplevel command causes
  21.                the  invoking procedure to disappear from the procedure
  22.                calling stack while the command is being executed.   In
  23.                the above example, suppose c invokes the command
  24.  
  25.                     uplevel 1 {set x 43; d}
  26.  
  27.                where d is another Tcl procedure.  The set command will
  28.                modify  the  variable  x  in  b's  context,  and d will
  29.                execute at level 3, as if called from b.  If it in turn
  30.                executes the command
  31.  
  32.                     uplevel {set x 42}
  33.                then the set command will modify the same variable x in
  34.                b's  context:  the procedure c does not appear to be on
  35.                the call stack when d is executing.  The command ``info
  36.                level''  may be used to obtain the level of the current
  37.                procedure.  Uplevel makes it possible to implement  new
  38.                control  constructs  as  Tcl  procedures  (for example,
  39.                uplevel could be used to implement the while  construct
  40.                as a Tcl procedure).
  41.